var tableData = {
	url : ctp + "/contractController/contractSearch.shtml",
	propertys : [ "NAME", "WORKTYPE", "GROUPNAME","VALIDATY","CONTRACTSTATE","HTCREATETIME"],
	hrefs : [ [ "function=contractUpdate", "recId=REC_ID", "编辑合同", null ],[ "function=contractDetail", "recId=REC_ID", "查看", null ] ],
	//css:[null,null,null,null,"[STATE_CHAR][1=color:blue;,2=color:red;]"],//不同值的样式
	//maxLength:["TASKNAME=15"],
	checkBox:["REC_ID",true],
	startLoad : function() {
		getListData(this);
	}
};


function searchData(curr) {
	setTagAndValue("form1", "curr", curr);
	tableData.startLoad();
}
$(document).ready(function() {
	getWorkerType();
	//页面中下拉框的渲染
	/*$('select').SumoSelect({
	placeholder: '请选择',
    csvDispCount: 4,
    captionFormat: '{0} Selected',
    forceCustomRendering: false,
    outputAsCSV : false,
    okCancelInMulti: false, 
    triggerChangeCombined : true
	});*/
	//页面加载时，加载列表
	searchData();
	
	

});


function contractDel() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择要清空所选工人的合同信息！");
		return false;
	}
	jconfirm("del('" + recIds + "')", "是否要清空所选工人的合同信息？");
}

function contractDelete(recIds) {
	jconfirm("del('" + recIds + "')", "是否要清空所选工人的合同信息？");
}
function del(recIds) {
	$.ajax({
		url : ctp + "/contractController/contractDelete.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			if (result == "") {
				jalert9("清除成功！");
				var curr = "1";
				if ($("#form1").find("#curr").length > 0) {
					curr = $("#curr").val();
				}
				searchData(curr);
			} else {
				jalert(result);
			}
		}
	});
}

// 修改
function contractUpdate(recId) {
	dialogWin(550, 450, ctp + "/contractController/contractUpdate.shtml?recId="
			+ recId, "");
}

//详情
function contractDetail(recId) {
	dialogWin(550, 450, ctp + "/contractController/contractDetail.shtml?recId="
			+ recId, "");
}

// 新增
function contractAdd() {
	/*layui.layer.open({
        type: 2,
        area: ['1000px', '510px'],
        title: "工人合同新增",
        fixed: false,
        maxmin: false,
        content: ctp + "/contractController/contractAdd.shtml"
    });*/
	dialogWin(550, 550, ctp + "/contractController/contractAdd.shtml", "");
}


// 重置密码
function resetPwd() {
	var recIds = getCheckIds(null, "contractid");
	if (recIds == '') {
		jalert("请选择记录！");
		return false;
	}
	jconfirm("doReset('" + recIds + "')", "确定要重置所选用户的密码吗？");
}

function doReset(recIds) {
	$.ajax({
		url : ctp + "/contractController/resetPwd.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			jalert9(result);
			setTimeout(function() {
				searchData();
			}, 1000);
		}
	});
}


function contractDisable() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择要停用的用户！");
		return false;
	}
	jconfirm("Disable('" + recIds + "')", "是否要停用所选的用户？");
}
function Disable(recIds) {
	$.ajax({
		url : ctp + "/contractController/contractDisable.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			if (result=='1') {
				jalert9("停用用户成功！");
				setTimeout(function(){
					searchData();
				}, WARN_TIME_OUT);
			} else {
				jalert("停用用户失败！");
			}
		}
	});
}

function contractEnable() {
	var recIds = getCheckIds();
	if (recIds == '') {
		jalert("请选择要启用的用户！");
		return false;
	}
	jconfirm("Enable('" + recIds + "')", "是否要启用所选的用户？");
}
function Enable(recIds) {
	$.ajax({
		url : ctp + "/contractController/contractEnable.shtml",
		data : {
			recIds : recIds
		},
		type : 'POST',
		async : false,
		success : function(result) {
			if (result=='1') {
				jalert9("启用用户成功！");
				setTimeout(function(){
					searchData();
				}, WARN_TIME_OUT);
			} else {
				jalert("启用用户失败！");
			}
		}
	});
}



function getWorkerType() {
	$.ajax({
		url : ctp + "/sysdictController/getDictListByType.shtml",
		data : {
			dicType : 'WORKER_TP'
		},
		type : "POST",
		cache : false,
		dataType : "json",
		success : function(data) {
			var list = data.list;
			var $str = '';
			$str += '<option value="">全部</option>';
			for (var i = 0; i < list.length; i++) {
				var l = list[i];
				$str += '<option value="' + l.rec_value + '">' + l.rec_value
						+ '</option>';
			}
			$('#workeType').html($str);
		}
	});
}






















